package com.zkdcloud.util;

import java.util.Random;
import java.util.UUID;

/**
 * random util
 * @author zk123
 * @version 2018/4/30
 */
public class RandomUtil {
    /**
     * 10
     */
    private static Character[] randomNumber = new Character[]{'1', '2', '3', '4', '5', '6', '7', '8', '9', '0'};

    /**
     * 随机random
     */
    private static Random random = new Random();

    /**
     * 获取uuid
     *
     * @return uuid
     */
    public static String getUUID(){
        return UUID.randomUUID().toString().replace("-","");
    }
    /**
     * 随机number 指定长度
     *
     * @param number number长度
     * @return string
     */
    public static String getRandomNumber(Integer number) {
        StringBuilder result = new StringBuilder();
        for (int i = 0; i < number; i++) {
            result.append(randomNumber[random.nextInt(10)]);
        }
        return result.toString();
    }
}
